
class MyArray<T extends Comparable<T>> {
    public T findMax(T[] arr) {
        T max = arr[0];
        for(int i = 0; i < arr.length; i++) {
            if(arr[i].compareTo(max) > 0) {
                max = arr[i];
            }
        }
        return max;
    }
}
class MyTest<T> {
    private Object[] array = new Object[10];

    public void setArray(int pos, T val) {
        array[pos] = val; // 向上转型
    }
    public T getArray(int pos) {
        return (T)array[pos];
    }
}
public class test2 {
    public static void main(String[] args) {
        MyArray<Integer> myArray = new MyArray<>();
        System.out.println(myArray.findMax(new Integer[]{1, 2, 3, 4, 5, 6}));
    }

    public static void main2(String[] args) {
        MyTest<Integer> myTest = new MyTest<>();
        myTest.setArray(0,2);
        myTest.setArray(1,3);
        System.out.println(myTest.getArray(0));

        MyTest<String> myTest1 = new MyTest<>();
        myTest1.setArray(0, "sdada");
        myTest1.setArray(1, "zhangsan");
        System.out.println(myTest1.getArray(0));



    }
    public static void main1(String[] args) {
        String s1 = new String("abc");
        char[] ch = new char[] {'a', 'b', 'c'};
        String s3 = new String(ch);
        s3.intern();
        s1.intern();
        String s2 = "abc";
        System.out.println(s1 == s2);
        System.out.println(s3 == s1);
    }
}
